package com.teen9g.infoplatformserver.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.teen9g.PageQueryDTO.CanteenShopPageQueryDTO;
import com.teen9g.PageQueryDTO.CanteenShopUserPageQueryDTO;
import com.teen9g.entity.CanteenShop;
import com.teen9g.userVO.CanteenShopUserVO;
import com.teen9g.vo.CanteenShopVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface CanteenShopMapper extends BaseMapper<CanteenShop> {
    @Select("select shop_id,shop_name,shop_at," +
            "shop_floor,shop_relative_position,shop_author from canteen_shop")
    List<CanteenShopVO> selectListFront();

    @Select("select shop_id,shop_name,shop_at," +
            "shop_floor,shop_relative_position,shop_author from canteen_shop where shop_at = '一食堂' ")
    List<CanteenShopVO> selectFirstAllFront();

    @Select("select shop_id,shop_name,shop_at," +
            "shop_floor,shop_relative_position,shop_author from canteen_shop where shop_at = '二食堂' ")
    List<CanteenShopVO> selectSecondAllFront();

    List<CanteenShopVO> selectByPage(CanteenShopPageQueryDTO pageQueryDTO);

    @Update("update canteen_shop set shop_view = shop_view + #{increment} where shop_id = #{shopId}")
    void updateViewCount(@Param("shopId") Integer shopId, @Param("increment") Integer increment);

    @Select("select * from canteen_shop order by shop_view desc limit #{topCount}")
    List<CanteenShop> selectTopTotalViewCanteenShops(int topCount);

    List<CanteenShop> selectTop10CanteenShopName(@Param("shopIds") List<Integer> shopIds);

    List<CanteenShopUserVO> selectByPageByUserId(CanteenShopUserPageQueryDTO pageQueryDTO);

    @Update("update canteen_shop set shop_comment_count = shop_comment_count + #{updateCount} where shop_id = #{relatedId}")
    void updateCommentCount(@Param("relatedId") Integer relatedId, @Param("updateCount") int updateCount);
}
